{%include file="header.tpl"%}
<script>

 function removeAllSpace(str){     
    var localString = '';     
    for(var index = 0; index<str.length; index++)     
        if(str.charCodeAt(index)!= 32){     
            localString += str.charAt(index);     
        };     
    return localString;     
    }     
  
 var powers=new Array("7","9","10","5","8","4","2","1","6","3","7","9","10","5","8","4","2");     
var parityBit=new Array("1","0","X","9","8","7","6","5","4","3","2");     
var sex="male";     
//验证身份证  
function validId(){   
	var obj = $("#identity_card").val();
    var _id=removeAllSpace(obj);    
    if(_id==""){  
       alert("身份证号码不能为空！");    
       return false;   
    }    
    var _valid=false;     
    if(_id.length==15){     
        _valid=validId15(_id);     
    }else if(_id.length==18){     
        _valid=validId18(_id);     
    }     
    if(!_valid){     
        alert("身份证号码有误！请您核对");     
        document.getElementById("identity_card").focus();  
        return false;     
    }     
    return true;  
}         
//18  
  
function validId18(_id){     
    _id=_id+"";     
    var _num=_id.substr(0,17);     
    var _parityBit=_id.substr(17);     
    var _power=0;     
    for(var i=0;i< 17;i++){     
  
        if(_num.charAt(i)<'0'||_num.charAt(i)>'9'){     
            return false;     
            break;     
        }else{     
  
            _power+=parseInt(_num.charAt(i))*parseInt(powers[i]);     
        }     
    }     
  
    var mod=parseInt(_power)%11;     
    if(parityBit[mod]==_parityBit){     
        return true;     
    }     
    return false;     
}     
//15  
  
function validId15(_id){     
    _id=_id+"";     
    for(var i=0;i<_id.length;i++){     
        if(_id.charAt(i)<'0'||_id.charAt(i)>'9'){     
            return false;     
            break;     
        }     
    }     
    var year=_id.substr(6,2);     
    var month=_id.substr(8,2);     
    var day=_id.substr(10,2);     
    var sexBit=_id.substr(14);     
  
    if(year<'01'||year >'90')return false;     
  
    if(month<'01'||month >'12')return false;     
  
    if(day<'01'||day >'31')return false;     
    return true;     
}


function isMobilePhone(){
	var partten = /^((\(\d{3}\))|(\d{3}\-))?13[0-9]\d{8}|15[0-9]\d{8}|189\d{8}$/;
	var obj = $("#user_mob").val();
	if(partten.test(obj)){
		return true ;
	}else{
		//$("#mob").html('请输入正确的手机号');
		alert('请输入正确的手机号');
		document.getElementById("user_mob").focus();  
		return false ;
	}
}

function is_real_name(){
	var obj = $("#real_name").val();
	if(obj!=''){
		return true ;
	}else{
		alert('请输入姓名');
		
		return false ;
	}
}

function is_ver_code(){
	var obj = $("#ver_code").val();
	if(obj!=''){
		return true ;
	}else{
		alert('请输入验证码');
		
		return false ;
	}
}

function is_checked(){
	if($("#check_agree").attr("checked")==false){
		alert('同意服务条款才能继续');
		return false;
	}else{
		return true;
	}
}

function ver_post(){
	//验证身份
	var obj = $("#identity_card").val();
    var _id=removeAllSpace(obj);    
    if(_id==""){  
       alert("身份证号码不能为空！");    
       return false;   
    }    
    var _valid=false;     
    if(_id.length==15){     
        _valid=validId15(_id);     
    }else if(_id.length==18){     
        _valid=validId18(_id);     
    }     
    if(!_valid){     
        alert("身份证号码有误！请您核对");     
        document.getElementById("identity_card").focus();  
        return false;     
    }     
	//验证手机
	var partten = /^((\(\d{3}\))|(\d{3}\-))?13[0-9]\d{8}|15[0-9]\d{8}|189\d{8}$/;
	var obj1 = $("#user_mob").val();
	if(!partten.test(obj1)){
		//$("#mob").html('请输入正确的手机号');
		alert('请输入正确的手机号');
		document.getElementById("user_mob").focus();  
		return false ;
	}
	     //验证验证码
	 var flag = true;
     $.ajax({
		type: "POST",
		async:false,
 		url: "ajax_vcode.php",
 		data:   {ver_code:$("#ver_code").val()},
 		dataType:'html',
 		success: function(data){
 			//验证成功
 			if(data!=''){
 				alert(data);
 				flag = false;
 			}else{
 				flag = true;
 			}
 		},
 		error: function(){
 			alert('系统错误');
 			flag = false;
 		}
	});
	//验证姓名
	var obj2 = $("#real_name").val();
	if(obj2==''){
		alert('请输入姓名');
		
		return false ;
	}
	
	return flag;

	
    
}
</script>
<div class="tanchu_01">
	<div class="tanchu_02"><p>http://www.idtag.cn为身份通登录官方域名 谨防假冒</p></div>
    <div class="tanchu_03"></div>
    <div class="tanchu_04">
    	<form name="form1" method="post" action="/second_step.php" onsubmit="return ver_post()">
    	<div class="tanch_neir01">
        	<p>身份通认证由国政通提供支持，可有效预防身份信息被冒用风险。</p>
			<p>认证通过点亮        徽章，并得到{%$coop_name%}网站更多的服务。</p>
        </div>
        <div class="tanch_neir02">
        	<p>通过身份通认证只需2步，请填写下面的表格，并点击下一步。</p>
            <div class="tanch_in">
                <div class="tanch_title">您的手机号：</div>
                <div class="tanch_kuinput">
                    <input type="text" name="user_mob" id="user_mob" class="tanch_input"/>
                    <span id="mob">支持移动、联通、电信手机</span>
                </div>
            </div>
            <div class="tanch_in">
                <div class="tanch_title">您的姓名：</div>
                <div class="tanch_kuinput">
                    <input type="text" name="real_name" id="real_name" class="tanch_input"/>
                    <span>请输入你身份证上的姓名</span>
                </div>
            </div>
            <div class="tanch_in">
                <div class="tanch_title">您的身份证号：</div>
                <div class="tanch_kuinput">
                    <input type="text" name="identity_card" id="identity_card" class="tanch_input"/>
                    <input type="hidden" name="temp_id" value="{%$temp_id%}">
                    <input type="hidden" name="icpcode" value="{%$icpcode%}">
                    <input type="hidden" name="user_id" value="{%$user_id%}">
                    <span>请输入15位或18位身份证号</span>
                </div>
            </div>
            <div class="tanch_in">
                <div class="tanch_title">验证码：</div>
           	  	<div class="tanch_kuinput">
                  	<div class="yanm"><input type="text" name="ver_code" id="ver_code"  class="tanch_input"/></div>
					<div class="yanm_img"><img src="/yz.php" align="absmiddle"  onclick="this.src='yz.php?a='+Math.random();"/></div>
                </div>
            </div>
            <div class="tanchu_chec">
                <input name="" type="checkbox" id="check_agree" value="" checked />
                我已经阅读并同意《身份通服务条款
            </div>
            <div class="tanchu_btn">
				<div class="tanchu_btn01"><button class="tanchu_btn01" title="" type="submit" >下一步</button></div>
                <div class="tanchu_btn02"><a href="/fourth_step.php?temp_id={%$temp_id%}">已通过身份通认证用户</a></div>
			</div>
        </div>
        </form>
    </div>
    <div class="tanchu_05"></div>

</div>
{%include file="footer.tpl"%}